

$(document).ready(function(){
  console.log(baseUrl)
  getAllCategory();
  getBannerImg();
  getShopDetail();
  gethotkey()
});

$('#shop-detail-box').on('click','.logisticBox',function(){
  console.log($(this).data)
  console.log($(this).data('shop-id'))
  window.location.href = fitness.html+'shopId='+$(this).data('shop-id');
});

// 获取首页导航栏信息
function getAllCategory(){
  $.ajax({
    url: baseUrl+"/hsent-xxyl-user/category/selectTSystemCategoryVo",
    type:"get",
    data:"",
    dataType:"json",
    success:function(res){
      console.log(res);
      if(res.status === 1){
        var data={
          data:res.data,
        };
        var html = template('stab-script', data);
        document.getElementById('stab-box').innerHTML = html;
        var html2 = template('StabC-script', data);
        document.getElementById('StabC').innerHTML = html2;
      }
    },
    error:function(res){

    },
  })
};

// 获取首页轮播图
function getBannerImg(){
  $.ajax({
    url: baseUrl+"/hsent-xxyl-user/homeBanner/getHomeBannerPc",
    type:"get",
    data:"",
    dataType:"json",
    success:function(res){
      console.log(res);
      if(res.status === 1){
        var data={
          data:res.data,
          pirUrl:picUrl
        };
        var html = template('swiper-wrapper-script', data);
        document.getElementById('swiper-wrapper').innerHTML = html;
        var mySwiper = new Swiper('.swiper-container', {
          swipeToNext: true,
          pagination : '.pagination',
          paginationClickable: true,
          autoplay: 5000, //可选选项，自动滑动
          loop: true, //可选选项，开启循环
        });

        $('#prve').click(function(){
          mySwiper.swipePrev();
        })
        $('#next').click(function(){
          mySwiper.swipeNext();
        })
      }
    },
    error:function(res){

    },
  })
};

// 获取店铺数据
function getShopDetail(){
  $.ajax({
    url: baseUrl+"/hsent-xxyl-user/solr/selectShopByKeyWordsPc",
    type:"get",
    data:"",
    dataType:"json",
    success:function(res){
      console.log(res);
      if(res.status === 1){
        var tempData = res.data;
        for(var i = 0 ; i < tempData.length ; i ++){
          for(var j = 0 ; j < tempData[i].list.length ; j ++){
            tempData[i].list[j].round =  Math.round(tempData[i].list[j].shopEvaluateValue);
            tempData[i].list[j].cha = 5-tempData[i].list[j].round;
          }
        }
        var data={
          data:tempData,
          pirUrl:picUrl
        };
        var html = template('goods-detail-script', data);
        document.getElementById('shop-detail-box').innerHTML = html;
      }
    },
    error:function(res){

    },
  })
}

// 搜索事件
function searchShop(){
	var str = $('#search').val()
    var param = {
      keyWords: str
    }
	$.ajax({
	  url: baseUrl+"/hsent-xxyl-user/solr/selectShopByKeyWords",
	  type:"get",
	  data:param,
	  dataType:"json",
	  success:function(res){
	    console.log(res);
	  },
	  error:function(res){
        console.log(res);
	  },
	})
}
// 搜索事件2
function searchShop2(){
  var str = $('#search').val()
  Tohref('screen.html?keyWords='+str)
}


